﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CellphoneRepair.Forms;

namespace CellphoneRepair
{
    public partial class Form1 : DevExpress.XtraEditors.XtraForm
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void barLargeButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LoadForm(new FrmRpts());
        }

        private void barLargeButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LoadForm(new Home());
        }

        private void LoadForm(Form frm)
        {
            var frms = this.MdiChildren;

            if (frms.Any(o => o.Name.Equals(frm.Name)))
            {
                frms.Single(o => o.Name.Equals(frm.Name)).Activate();

                frm.Dispose();
            }
            else
            {
                frm.MdiParent = this;

                frm.Tag = this;

                frm.Show();
            }
        }

        private void barLargeButtonItem2_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LoadForm(new Itmes());
        }

        private void barLargeButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            LoadForm(new FrmRepairList()); }

    }
}

